﻿#include "fsConfig.h"
#include "tool.h"

fsConfig::fsConfig()
{
    memset(&designVar,0,sizeof(designVar));
    memset(&uimVar,0,sizeof(uimVar));
}

fsConfig::~fsConfig()
{
}

QVariant fsConfig::getUiWindow(const char *key, const char *defaultValue){
    return getConfig("WINDOW",key,defaultValue);
}

QVariant fsConfig::getUiFunc(const char *key, const char *defaultValue){
    return getConfig("FUNC",key,defaultValue);
}

QVariant fsConfig::getUiList(const char *key, const char *defaultValue){
    return getConfig("LIST",key,defaultValue);
}

QVariant fsConfig::getConfig(const char *set, const char *key, const char *defaultValue){
    QVariant ret = configIni->value(QString("/%0/%1").arg(set).arg(key));
    // qDebug()<< "getUI-" << set << "-" << key << "-" << ret.type();
    if(ret.type()==QVariant::Invalid){
        //非法键
        retInfo(QString("非法键 /%0/%1/").arg(set).arg(key));
        configIni->setValue(QString("/%0/%1/").arg(set).arg(key),defaultValue);
        ret = configIni->value(QString("/%0/%1").arg(set).arg(key));
    }
    return ret;
}

QVariant fsConfig::getConfigDesign(const char *key, const char *defaultValue){
    return getConfig("DESIGN",key,defaultValue);
}

QVariant fsConfig::getConfigMvs(const char *key, const char *defaultValue){
    return getConfig("MVS",key,defaultValue);
}

QVariant fsConfig::getConfigProc(const char *key, const char *defaultValue){
    return getConfig("PROC",key,defaultValue);
}

QVariant fsConfig::getConfigUim(const char *key, const char *defaultValue){
    return getConfig("UIM",key,defaultValue);
}

void fsConfig::setConfName(const QString path,const QString name){
    confName = QString("%0/%1").arg(path).arg(name);
}

void fsConfig::readUi(void)
{
    retInfo(uiName);
    configIni = new QSettings(uiName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    qStrToCstr(getUiWindow("Title").toString(),
               winVar.Title,sizeof(winVar.Title));
    qStrToCstr(getUiWindow("ConfName").toString(),
               winVar.ConfName,sizeof(winVar.ConfName));
    winVar.WindowMax = qStrToInt(getUiWindow("WindowMax").toString());
    // char    SoftKey[64];            //软件锁ID

    funcVar.SysDog = qStrToInt(getUiFunc("SysDog").toString());
    funcVar.AddSetup = qStrToInt(getUiFunc("AddSetup").toString());
    funcVar.AddSound = qStrToInt(getUiFunc("AddSound").toString());
    funcVar.Debug = qStrToInt(getUiFunc("Debug").toString());
    funcVar.Log = qStrToInt(getUiFunc("Log").toString());
    funcVar.Style = qStrToInt(getUiFunc("Style").toString());

    qStrToCstr(getUiList("ListFilter").toString(),
               listVar.ListFilter,sizeof(listVar.ListFilter));
    qStrToCstr(getUiList("SaveResultPath").toString(),
               listVar.SaveResultPath,sizeof(listVar.SaveResultPath));
    qStrToCstr(getUiList("SaveImagePath").toString(),
               listVar.SaveImagePath,sizeof(listVar.SaveImagePath));
    qStrToCstr(getUiList("SaveDirFormat").toString(),
               listVar.SaveDirFormat,sizeof(listVar.SaveDirFormat));
    listVar.SaveFileLen = qStrToInt(getUiList("SaveFileLen").toString());
    qStrToCstr(getUiList("ListCurDir").toString(),
               listVar.ListCurDir,sizeof(listVar.ListCurDir));
    qStrToCstr(getUiList("ListCurName").toString(),
               listVar.ListCurName,sizeof(listVar.ListCurName));

    delete configIni;
}

void fsConfig::readConf(void)
{
    retInfo(confName);
    configIni = new QSettings(confName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");
    // DESIGN
    designVar.UIWindow4KWidth = qStrToFloat(getConfigDesign("UIWindow4KWidth").toString());
    designVar.UIWindow4KHeight = qStrToFloat(getConfigDesign("UIWindow4KHeight").toString());
    designVar.MouseWheelStep = qStrToInt(getConfigDesign("MouseWheelStep").toString());
    designVar.MouseMoveStep = qStrToInt(getConfigDesign("MouseMoveStep").toString());
    // designVar.LogoPhotoNums = qStrToInt(getConfigDesign("LogoPhotoNums").toString());
    // designVar.LogoTitleWidth = qStrToInt(getConfigDesign("LogoTitleWidth").toString());
    // designVar.LogoTitleWidth4K = qStrToInt(getConfigDesign("LogoTitleWidth4K").toString());
    // designVar.LogoTitleHeight = qStrToInt(getConfigDesign("LogoTitleHeight").toString());
    // designVar.LogoTitleHeight4K = qStrToInt(getConfigDesign("LogoTitleHeight4K").toString());
    designVar.LogoPhotoWidth = qStrToInt(getConfigDesign("LogoPhotoWidth").toString());
    designVar.LogoPhotoWidth4K = qStrToInt(getConfigDesign("LogoPhotoWidth4K").toString());
    designVar.LogoPhotoHeight = qStrToInt(getConfigDesign("LogoPhotoHeight").toString());
    designVar.LogoPhotoHeight4K = qStrToInt(getConfigDesign("LogoPhotoHeight4K").toString());
    qStrToCstr(getConfigDesign("LogoPhotoSheet1").toString(),
               designVar.LogoPhotoSheet1,sizeof(designVar.LogoPhotoSheet1));
    qStrToCstr(getConfigDesign("LogoPhotoSheet2").toString(),
               designVar.LogoPhotoSheet2,sizeof(designVar.LogoPhotoSheet2));
    // designVar.FocusAssistWidth = qStrToInt(getConfigDesign("FocusWidth").toString());
    // designVar.FocusAssistWidth4K = qStrToInt(getConfigDesign("FocusWidth4K").toString());
    // designVar.FocusAssistHeight = qStrToInt(getConfigDesign("FocusHeight").toString());
    // designVar.FocusAssistHeight4K = qStrToInt(getConfigDesign("FocusHeight4K").toString());
    // qStrToCstr(getConfigDesign("FocusSheet").toString(),
    //            designVar.FocusAssistSheet,sizeof(designVar.FocusAssistSheet));
    // designVar.FocusAssistNums = qStrToInt(getConfigDesign("FocusAssistNums").toString());
    // designVar.FocusAssistBufLen = qStrToInt(getConfigDesign("FocusAssistBufLen").toString());
    // designVar.FocusAssistBufLen4K = qStrToInt(getConfigDesign("FocusAssistBufLen4K").toString());
    qStrToCstr(getConfigDesign("SplitterPhotoSizes").toString(),
               designVar.SplitterPhotoSizes,sizeof(designVar.SplitterPhotoSizes));
    qStrToCstr(getConfigDesign("SplitterMainSizes").toString(),
               designVar.SplitterMainSizes,sizeof(designVar.SplitterMainSizes));
    qStrToCstr(getConfigDesign("SplitterWindowSizes").toString(),
               designVar.SplitterWindowSizes,sizeof(designVar.SplitterWindowSizes));
    // designVar.NegativeImage = qStrToInt(getConfigDesign("NegativeImage").toString());
    // designVar.ImageFormat = qStrToInt(getConfigDesign("ImageFormat").toString());
//    designVar.MapMode = qStrToInt(getConfigDesign("MapMode").toString());
    designVar.SaveFormat = qStrToInt(getConfigDesign("SaveFormat").toString());
    qStrToCstr(getConfigDesign("SaveFileExt").toString(),
               designVar.SaveFileExt,sizeof(designVar.SaveFileExt));
    designVar.Para = qStrToInt(getConfigDesign("Para").toString());
    designVar.SaveHeight = qStrToInt(getConfigDesign("SaveHeight").toString());
    qStrToCstr(getConfigDesign("SaveDPIList").toString(),
               designVar.SaveDPIList,sizeof(designVar.SaveDPIList));
    designVar.SaveDPI = qStrToInt(getConfigDesign("SaveDPI").toString());
    // designVar.SaveNegative = qStrToInt(getConfigDesign("SaveNegative").toString());
    // designVar.Negative = qStrToInt(getConfigDesign("Negative").toString());
    // designVar.Vertical = qStrToInt(getConfigDesign("Vertical").toString());
    // designVar.Horizontal = qStrToInt(getConfigDesign("Horizontal").toString());
    // designVar.FilmPhoto = qStrToInt(getConfigDesign("FilmPhoto").toString());
    // designVar.RotatePhoto = qStrToInt(getConfigDesign("RotatePhoto").toString());
    // designVar.RotatePreview = qStrToInt(getConfigDesign("RotatePreview").toString());
    // designVar.Resolution = qStrToInt(getConfigDesign("Resolution").toString());
    // designVar.SaveImageWidth = qStrToInt(getConfigDesign("SaveImageWidth").toString());
    // designVar.SaveImageHeight = qStrToInt(getConfigDesign("SaveImageHeight").toString());
    designVar.FrameEnable = qStrToInt(getConfigDesign("FrameEnable").toString());
    //拍照编辑.纠偏
    // designVar.PhotoImageEdit = qStrToInt(getConfigDesign("PhotoImageEdit").toString());
    // designVar.ImageCorrent = qStrToInt(getConfigDesign("ImageCorrent").toString());
    // designVar.ImageEditWidth = qStrToInt(getConfigDesign("ImageEditWidth").toString());
    // designVar.ImageEditHeight = qStrToInt(getConfigDesign("ImageEditHeight").toString());
    // designVar.ListIconWidth = qStrToInt(getConfigDesign("ListIconWidth").toString());
    // designVar.ListIconWidth4K = qStrToInt(getConfigDesign("ListIconWidth4K").toString());
    // designVar.ListIconHeight = qStrToInt(getConfigDesign("ListIconHeight").toString());
    // designVar.ListIconHeight4K = qStrToInt(getConfigDesign("ListIconHeight4K").toString());
    // designVar.ListLeftWidth = qStrToInt(getConfigDesign("ListLeftWidth").toString());
    // designVar.ListLeftWidth4K = qStrToInt(getConfigDesign("ListLeftWidth4K").toString());
    // designVar.ListTextHeight = qStrToInt(getConfigDesign("ListTextHeight").toString());
    // designVar.ListTextHeight4K = qStrToInt(getConfigDesign("ListTextHeight4K").toString());
    // designVar.ListSpaceHeight = qStrToInt(getConfigDesign("ListSpaceHeight").toString());
    // designVar.ListSpaceHeight4K = qStrToInt(getConfigDesign("ListSpaceHeight4K").toString());

    // designVar.TooltipWindowWidth = qStrToInt(getConfigDesign("TooltipWindowWidth").toString());
    // designVar.TooltipWindowWidth4K = qStrToInt(getConfigDesign("TooltipWindowWidth4K").toString());
    // designVar.TooltipWindowHeight = qStrToInt(getConfigDesign("TooltipWindowHeight").toString());
    // designVar.TooltipWindowHeight4K = qStrToInt(getConfigDesign("TooltipWindowHeight4K").toString());

    // designVar.ImageZoomMax = qStrToInt(getConfigDesign("ImageZoomMax").toString());
    designVar.ComboBoxItemHeight = qStrToInt(getConfigDesign("ComboBoxItemHeight").toString());
    designVar.ComboBoxItemHeight4K = qStrToInt(getConfigDesign("ComboBoxItemHeight4K").toString());
    designVar.UiSetupWindowWidth = qStrToInt(getConfigDesign("UiSetupWindowWidth").toString());
    designVar.UiSetupWindowHeight = qStrToInt(getConfigDesign("UiSetupWindowHeight").toString());
    designVar.UiSetupWindowWidth4K = qStrToInt(getConfigDesign("UiSetupWindowWidth4K").toString());
    designVar.UiSetupWindowHeight4K = qStrToInt(getConfigDesign("UiSetupWindowHeight4K").toString());

    designVar.FrameImageZoomMax = qStrToInt(getConfigDesign("FrameImageZoomMax").toString());
    designVar.ResultImageZoomMax = qStrToInt(getConfigDesign("ResultImageZoomMax").toString());

    //MVS
    mvsVar.Debug = qStrToInt(getConfigMvs("Debug").toString());
    mvsVar.Log = qStrToInt(getConfigMvs("Log").toString());
    mvsVar.AutoFind = getConfigMvs("AutoFind").toBool();
    qStrToCstr(getConfigMvs("MvsStartTitle").toString(),
               mvsVar.MvsStartTitle,sizeof(mvsVar.MvsStartTitle));
    qStrToCstr(getConfigMvs("MvsCloseTitle").toString(),
               mvsVar.MvsCloseTitle,sizeof(mvsVar.MvsCloseTitle));
    qStrToCstr(getConfigMvs("MvsStartAcquisition").toString(),
               mvsVar.MvsStartAcquisition,sizeof(mvsVar.MvsStartAcquisition));
    qStrToCstr(getConfigMvs("MvsCloseAcquisition").toString(),
               mvsVar.MvsCloseAcquisition,sizeof(mvsVar.MvsCloseAcquisition));
    mvsVar.MvsSaveFrameNums = qStrToInt(getConfigMvs("MvsSaveFrameNums").toString());
    mvsVar.MvsPreviewBorder = qStrToInt(getConfigMvs("MvsPreviewBorder").toString());
    mvsVar.MvsResultBorder = qStrToInt(getConfigMvs("MvsResultBorder").toString());

    //PROC
    procVar.ContourGaussian = qStrToInt(getConfigProc("ContourGaussian").toString());
    procVar.ContourTwoBorder = qStrToInt(getConfigProc("ContourTwoBorder").toString());
    procVar.ContourThresh = qStrToInt(getConfigProc("ContourThresh").toString());
    procVar.ContourMinWidth = qStrToInt(getConfigProc("ContourMinWidth").toString());
    procVar.ContourMinHeight = qStrToInt(getConfigProc("ContourMinHeight").toString());
    procVar.ContourMaxWidth = qStrToInt(getConfigProc("ContourMaxWidth").toString());
    procVar.ContourUpDownBorder = qStrToInt(getConfigProc("ContourUpDownBorder").toString());
    procVar.ContourLeftRightBorder = qStrToInt(getConfigProc("ContourLeftRightBorder").toString());
    procVar.ProcImageWidth = qStrToInt(getConfigProc("ProcImageWidth").toString());
    procVar.ProcTime = qStrToInt(getConfigProc("ProcTime").toString());

    //UIM
    qStrToCstr(getConfigUim("Title").toString(),
               uimVar.Title,sizeof(uimVar.Title));
    uimVar.Debug = qStrToInt(getConfigUim("Debug").toString());
    uimVar.Log = qStrToInt(getConfigUim("Log").toString());
    qStrToCstr(getConfigUim("UIMStartTitle").toString(),
               uimVar.UIMStartTitle,sizeof(uimVar.UIMStartTitle));
    qStrToCstr(getConfigUim("UIMCloseTitle").toString(),
               uimVar.UIMCloseTitle,sizeof(uimVar.UIMCloseTitle));
    uimVar.UIMUsbPort = qStrToInt(getConfigUim("UIMUsbPort").toString());
    uimVar.UIMComPort = qStrToInt(getConfigUim("UIMComPort").toString());
    // uimVar.UIMComPos = qStrToInt(getConfigUim("UIMComPos").toString());
    // uimVar.UIMComRate = qStrToInt(getConfigUim("UIMComRate").toString());
    uimVar.UIMCanTimer = qStrToInt(getConfigUim("UIMCanTimer").toString());
    uimVar.UIMCanLimitTimer = qStrToInt(getConfigUim("UIMCanLimitTimer").toString());
    uimVar.UIMCanSelectTimer = qStrToInt(getConfigUim("UIMCanSelectTimer").toString());
    uimVar.EncodeTimer = qStrToInt(getConfigUim("EncodeTimer").toString());
    uimVar.EncodeNums = qStrToInt(getConfigUim("EncodeNums").toString());
    //上下电机
    qStrToCstr(getConfigUim("FocusTitle").toString(),
               uimVar.FocusTitle,sizeof(uimVar.FocusTitle));
    qStrToCstr(getConfigUim("UIMFocusLabel").toString(),
               uimVar.UIMFocusLabel,sizeof(uimVar.UIMFocusLabel));
    qStrToCstr(getConfigUim("UIMFocusMoveTitle1").toString(),
               uimVar.UIMFocusMoveTitle[0],sizeof(uimVar.UIMFocusMoveTitle[0]));
    qStrToCstr(getConfigUim("UIMFocusMoveTitle2").toString(),
               uimVar.UIMFocusMoveTitle[1],sizeof(uimVar.UIMFocusMoveTitle[1]));
    uimVar.UIMNodeIdFocus = qStrToInt(getConfigUim("UIMNodeIdFocus").toString());
    uimVar.UIMCanRateFocus = qStrToInt(getConfigUim("UIMCanRateFocus").toString());
    uimVar.UIMCanRateFocusLocate = qStrToInt(getConfigUim("UIMCanRateFocusLocate").toString());
    uimVar.UIMCanStepFocus = qStrToInt(getConfigUim("UIMCanStepFocus").toString());
    uimVar.UIMCanStepFocusLocate = qStrToInt(getConfigUim("UIMCanStepFocusLocate").toString());
    uimVar.UIMCanFocusOrg = qStrToInt(getConfigUim("UIMCanFocusOrg").toString());
    uimVar.UIMCanFocusFar = qStrToInt(getConfigUim("UIMCanFocusFar").toString());
    uimVar.UIMCanFocusLimit1 = qStrToInt(getConfigUim("UIMCanFocusLimit1").toString());
    uimVar.UIMCanFocusLimit2 = qStrToInt(getConfigUim("UIMCanFocusLimit2").toString());
    uimVar.UIMCanFocusMode = qStrToInt(getConfigUim("UIMCanFocusMode").toString());
    //卷片扫描
    uimVar.UIMCanRatePhoto = qStrToInt(getConfigUim("UIMCanRatePhoto").toString());
    //右收片
    uimVar.UIMNodeIdRight = qStrToInt(getConfigUim("UIMNodeIdRight").toString());
    qStrToCstr(getConfigUim("UIMRightMoveTitle1").toString(),
               uimVar.UIMRightMoveTitle[0],sizeof(uimVar.UIMRightMoveTitle[0]));
    qStrToCstr(getConfigUim("UIMRightMoveTitle2").toString(),
               uimVar.UIMRightMoveTitle[1],sizeof(uimVar.UIMRightMoveTitle[1]));
    uimVar.UIMCanRateRight = qStrToInt(getConfigUim("UIMCanRateRight").toString());
    uimVar.UIMCanStepRight = qStrToInt(getConfigUim("UIMCanStepRight").toString());
    uimVar.UIMCanRateTakeupRight = qStrToInt(getConfigUim("UIMCanRateTakeupRight").toString());
    uimVar.UIMCanEncodeStop = qStrToInt(getConfigUim("UIMCanEncodeStop").toString());
    uimVar.UIMCanEncodeOver = qStrToInt(getConfigUim("UIMCanEncodeOver").toString());

    delete configIni;
}

void fsConfig::saveConfigDesignWindow(void){
    configIni = new QSettings(confName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    configIni->setValue("/DESIGN/SplitterPhotoSizes",QString("%0").arg(designVar.SplitterPhotoSizes));
    configIni->setValue("/DESIGN/SplitterMainSizes",QString("%0").arg(designVar.SplitterMainSizes));
    configIni->setValue("/DESIGN/SplitterWindowSizes",QString("%0").arg(designVar.SplitterWindowSizes));

    delete configIni;
}


void fsConfig::saveConfigDesignPara(void){
    configIni = new QSettings(confName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    // configIni->setValue("/DESIGN/NegativeImage",QString("%0").arg(designVar.NegativeImage));
    // configIni->setValue("/DESIGN/ImageFormat",QString("%0").arg(designVar.ImageFormat));
    configIni->setValue("/DESIGN/SaveFormat",QString("%0").arg(designVar.SaveFormat));
    configIni->setValue("/DESIGN/Para",QString("%0").arg(designVar.Para));
    configIni->setValue("/DESIGN/SaveHeight",QString("%0").arg(designVar.SaveHeight));
    configIni->setValue("/DESIGN/SaveDPI",QString("%0").arg(designVar.SaveDPI));

    delete configIni;
}

void fsConfig::saveConfigDesignSaveImage(void){
    configIni = new QSettings(confName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    configIni->setValue("/DESIGN/Resolution",QString("%0").arg(designVar.Resolution));
    configIni->setValue("/DESIGN/SaveImageWidth",QString("%0").arg(designVar.SaveImageWidth));
    configIni->setValue("/DESIGN/SaveImageHeight",QString("%0").arg(designVar.SaveImageHeight));

    delete configIni;
}

void fsConfig::saveConfigProc(void){
    configIni = new QSettings(confName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    configIni->setValue("/PROC/ContourGaussian",QString("%0").arg(procVar.ContourGaussian));
    configIni->setValue("/PROC/ContourTwoBorder",QString("%0").arg(procVar.ContourTwoBorder));
    configIni->setValue("/PROC/ContourThresh",QString("%0").arg(procVar.ContourThresh));
    configIni->setValue("/PROC/ContourMinWidth",QString("%0").arg(procVar.ContourMinWidth));
    configIni->setValue("/PROC/ContourMinHeight",QString("%0").arg(procVar.ContourMinHeight));
    configIni->setValue("/PROC/ContourUpDownBorder",QString("%0").arg(procVar.ContourUpDownBorder));
    configIni->setValue("/PROC/ContourLeftRightBorder",QString("%0").arg(procVar.ContourLeftRightBorder));
    configIni->setValue("/PROC/ProcImageWidth",QString("%0").arg(procVar.ProcImageWidth));

    delete configIni;
}

void fsConfig::saveConfigListSave(void){
    configIni = new QSettings(uiName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    configIni->setValue("/LIST/SaveImagePath", QString("%0").arg(listVar.SaveImagePath));
    configIni->setValue("/LIST/SaveResultPath", QString("%0").arg(listVar.SaveResultPath));
    // configIni->setValue("/LIST/ListCurDir",QString("%0").arg(listVar.ListCurDir));
    // configIni->setValue("/LIST/ListCurName",QString("%0").arg(listVar.ListCurName));

    delete configIni;
}

void fsConfig::saveConfigFuncSave(void){
    configIni = new QSettings(uiName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    configIni->setValue("/FUNC/Debug", QString("%0").arg(funcVar.Debug));
    configIni->setValue("/FUNC/Log", QString("%0").arg(funcVar.Log));

    delete configIni;
}

void fsConfig::saveConfigUimConf(void)
{
    configIni = new QSettings(confName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    configIni->setValue(QString("/UIM/Debug"),
                        QString("%0").arg(uimVar.Debug));
    configIni->setValue(QString("/UIM/UIMUsbPort"),
                        QString("%0").arg(uimVar.UIMUsbPort));
    configIni->setValue(QString("/UIM/UIMComPort"),
                        QString("%0").arg(uimVar.UIMComPort));

    configIni->setValue(QString("/UIM/UIMNodeIdFocus"),
                        QString("%0").arg(uimVar.UIMNodeIdFocus));

    configIni->setValue(QString("/UIM/UIMCanRateFocus"),
                        QString("%0").arg(uimVar.UIMCanRateFocus));
    configIni->setValue(QString("/UIM/UIMCanRateFocusLocate"),
                        QString("%0").arg(uimVar.UIMCanRateFocusLocate));
    configIni->setValue(QString("/UIM/UIMCanStepFocus"),
                        QString("%0").arg(uimVar.UIMCanStepFocus));
    configIni->setValue(QString("/UIM/UIMCanStepFocusLocate"),
                        QString("%0").arg(uimVar.UIMCanStepFocusLocate));

    //Far
    configIni->setValue(QString("/UIM/UIMCanFocusOrg"),
                        QString("%0").arg(uimVar.UIMCanFocusOrg));
    configIni->setValue(QString("/UIM/UIMCanFocusFar"),
                        QString("%0").arg(uimVar.UIMCanFocusFar));

    //Limit
    configIni->setValue(QString("/UIM/UIMCanFocusLimit1"),
                        QString("%0").arg(uimVar.UIMCanFocusLimit1));
    configIni->setValue(QString("/UIM/UIMCanFocusLimit2"),
                        QString("%0").arg(uimVar.UIMCanFocusLimit2));
    configIni->setValue(QString("/UIM/UIMCanFocusMode"),
                        QString("%0").arg(uimVar.UIMCanFocusMode));

    configIni->setValue(QString("/UIM/UIMCanRateRight"),
                        QString("%0").arg(uimVar.UIMCanRateRight));
    configIni->setValue(QString("/UIM/UIMCanStepRight"),
                        QString("%0").arg(uimVar.UIMCanStepRight));
    configIni->setValue(QString("/UIM/UIMCanRateTakeupRight"),
                        QString("%0").arg(uimVar.UIMCanRateTakeupRight));

    configIni->setValue(QString("/UIM/UIMCanRatePhoto"),
                        QString("%0").arg(uimVar.UIMCanRatePhoto));

    delete configIni;
}

void fsConfig::saveConfigUimReset(void){
    configIni = new QSettings(confName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    configIni->setValue(QString("/UIM/UIMCanStepFocusLocate"),
                        QString("%0").arg(uimVar.UIMCanStepFocusLocate));

    delete configIni;
}

void fsConfig::saveConfigUimPhoto(void){
    configIni = new QSettings(confName, QSettings::IniFormat);
    configIni->setIniCodec("UTF-8");

    configIni->setValue(QString("/UIM/UIMCanRateRight"),
                        QString("%0").arg(uimVar.UIMCanRateRight));
    configIni->setValue(QString("/UIM/UIMCanRatePhoto"),
                        QString("%0").arg(uimVar.UIMCanRatePhoto));
    configIni->setValue(QString("/UIM/UIMCanEncodeStop"),
                        QString("%0").arg(uimVar.UIMCanEncodeStop));

    delete configIni;
}
